package com.beiing.tianshuai.tianshuai.huodong.presenter;

import com.beiing.tianshuai.tianshuai.dongtai.CallBack;
import com.beiing.tianshuai.tianshuai.entity.HuoDongItemBean;
import com.beiing.tianshuai.tianshuai.huodong.model.HuoDongAllModel;
import com.beiing.tianshuai.tianshuai.huodong.model.HuoDongAllModelImpl;
import com.beiing.tianshuai.tianshuai.huodong.view.HuoDongAllViewImpl;

/**
 * Created by magikliu on 2017/9/10.
 */

public class HuoDongAllPresenter implements HuoDongAllPresenterImpl {

    private HuoDongAllViewImpl mView;
    private HuoDongAllModelImpl mModel;

    public HuoDongAllPresenter(HuoDongAllViewImpl mView) {
        this.mView = mView;
        this.mModel = new HuoDongAllModel();
    }

    @Override
    public void getAllHuoDong(int firstRow, int listRows, final int type) {
        mView.showProgress();
        mModel.getAllHuoDong(firstRow, listRows, new CallBack<HuoDongItemBean>() {

            @Override
            public void result(HuoDongItemBean bean) {
                if (type == 0){         //普通获取数据
                    mView.showAllHuoDong(bean);
                } else {                //下拉刷新
                    mView.refreshHuoDong(bean);
                }
                mView.hideProgress();
            }

            @Override
            public void error(Throwable e) {
                mView.showError(0);
                mView.hideProgress();
            }
        });
    }
}
